<?php

namespace Modules\Shop\Entities;

use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
    //protected $fillable = ['title','author','content','thumb','click','iscommend','category_id'];
	protected $guarded=['file'];
	public function category(){
        //模型关联其实是用当前模型去关联另外一个模型
        //如果被关联模型中的关联字段是当前模型的名称加上_id,并且当前模型的主键是id,两者都可以省略,默认框架会用当前模型加上_id的字段去被关联模型中找这个字段关联
		return $this->belongsTo (Category::class);
	}

    public function comment(){
        return $this->hasMany(Comment::class,'article_id','id');
    }

}
